package com.tanglongan.concurrent._basic;

public class Demo22 {
    public static void main(String[] args) {
        Thread t1 = new Demo22Thread();
        t1.start();
    }

}

class Demo22Thread extends Thread {
    @Override
    public void run() {
        int count = 0;
        long start = System.currentTimeMillis();
        for (int i = 0; i < 500000; i++) {
            Thread.yield();  //让出CPU资源
            count += i + 1;
        }
        System.out.println(count);
        long end = System.currentTimeMillis();
        System.out.println("用时：" + (end - start) + "毫秒");
    }
}
